package com.sdkj.dspservice.common.utils;

import org.hashids.Hashids;

/**
 * HashIds工具类
 */
public class HashIdsUtils {

    /**
     * 盐值
     */
    private static final String salt = "0qDw6JujBPzPbAsr";
    /**
     * 长度
     */
    private static final int length = 8;
    private static final Hashids hashids = new Hashids(salt, length);


    /**
     * 加密
     * @param id
     * @return
     */
    public static String encode(int id){
        return hashids.encode(id);
    }

    /**
     * 解密
     * @param hashString
     * @return
     */
    public static long[] decode(String hashString){
        return hashids.decode(hashString);
    }

    public static void main(String[] args) {
        System.out.println(encode(52));
    }

}
